package com.poisonh.unifiedauth.ui.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.poisonh.unifiedauth.R;
import com.poisonh.unifiedauth.model.IdCard;
import com.poisonh.unifiedauth.utils.ConstantUitls;

/**
 * Created by wish30_2 on 2017/2/28.
 */

@SuppressLint("ValidFragment")
public class IdCardFragment extends BaseCardFragment {

    private IdCard idCard;
    public IdCardFragment(IdCard idCard) {
        super(R.layout.fragment_id_card);
        this.idCard = idCard;
    }

    @Override
    protected void bindData(View view, Bundle savedInstanceState) {

        ImageView ivHeadImg = (ImageView)view.findViewById(R.id.iv_id_card_head_img);

        Glide.with(this).load(ConstantUitls.REQUEDT_IMG_URL +idCard.getHeadImg()).into(ivHeadImg);

        TextView tvName = (TextView)view.findViewById(R.id.tv_id_card_name);
        TextView tvSex = (TextView)view.findViewById(R.id.tv_id_card_sex);
        TextView tvFamilyName = (TextView)view.findViewById(R.id.tv_id_card_family_name);
        TextView tvYear = (TextView)view.findViewById(R.id.tv_id_card_year);
        TextView tvMonth = (TextView)view.findViewById(R.id.tv_id_card_month);
        TextView tvDay = (TextView)view.findViewById(R.id.tv_id_card_day);
        TextView tvAddress = (TextView)view.findViewById(R.id.tv_id_card_address);
        TextView tvIdNumber = (TextView)view.findViewById(R.id.tv_id_card_id_number);

        tvName.setText(idCard.getName());
        tvSex.setText(idCard.getSex());
        tvFamilyName.setText(idCard.getFamilyName());

        try {
            String birth = idCard.getBirth();
            String[] ss = birth.split("-");
            if (ss.length == 3) ;
            {
                tvYear.setText(ss[0]);
                tvMonth.setText(ss[1]);
                tvDay.setText(ss[2].substring(0,2));
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
       // tvAddress.setText(idCard.getAddress());
        tvAddress.setText(idCard.getAddress());
        tvIdNumber.setText(idCard.getIdNumber());
    }
}
